import requests
from pycacho.cachobase.logger import Logger
import threading
from pacong.stock.stock_config import db,cursor,headers
logger = Logger("get_stock_sample").get_log()

lock = threading.Lock()

def get_CoreConception(stock_no):
    info_url = 'https://emweb.securities.eastmoney.com/PC_HSF10/CoreConception/PageAjax?code={0}'.format(stock_no)
    resp = requests.get(info_url, headers=headers)
    data = resp.json()
    logger.info("股票公司核心题材链接为：%s", info_url)
    core_stNo = stock_no[2:]
    board_info = data['ssbk']
    board_name = '所属板块'
    info = ''
    for board in board_info:
        info= info +board['BOARD_NAME']+' '
    print(core_stNo,board_name,info)
    core_info = data['hxtc']
    for core in core_info:
        #print(core)
        core_theme = core['KEYWORD']
        core_detail = core['MAINPOINT_CONTENT']
        with lock:
            print(core_stNo, core_theme, core_detail)
            # self.coreInfo_to_mysql(core_stNo,core_theme,core_detail)

if __name__ == '__main__':
    get_CoreConception('SH600166')